<!DOCTYPE html>


<html lang="zh-CN">
  

    <head>
      <meta charset="utf-8" />
       
      <meta name="keywords" content="陈亚东 cyd 凤舞神者" />
       
      <meta name="description" content="85年的精神小伙,不是神者有点神经,水尿吧汤 " />
      
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>clickHouse常用命令 |  风舞神者</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/favicon.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-clickHouse常用命令"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  clickHouse常用命令
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/08/16/clickHouse%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="article-date">
  <time datetime="2023-08-16T02:05:49.000Z" itemprop="datePublished">2023-08-16</time>
</a>   
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">3.2k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">14 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="常用存储间类型对照，包含mysql-clickhouse-oracle-hive-flink-SQL"><a href="#常用存储间类型对照，包含mysql-clickhouse-oracle-hive-flink-SQL" class="headerlink" title="常用存储间类型对照，包含mysql,clickhouse,oracle,hive,flink SQL"></a>常用存储间类型对照，包含mysql,clickhouse,oracle,hive,flink SQL</h1><p>转载：<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44056920/article/details/119826740">https://blog.csdn.net/weixin_44056920/article/details/119826740</a></p>
<p>不同存储间数据传输的时候，类型匹配是个很让人头疼的事情，笔者总结了常用几种存储的类型对照，以供参考。有不准确的地方，欢迎批评指正~</p>
<table>
<thead>
<tr>
<th>Java类型</th>
<th>MySQL类型</th>
<th>ClickHouse类型</th>
<th>Oracle类型</th>
<th>Hive类型</th>
<th>Flink SQL类型</th>
</tr>
</thead>
<tbody><tr>
<td>boolean</td>
<td>boolean tinyint(1)</td>
<td>UInt8</td>
<td>NUMBER(1)</td>
<td>boolean</td>
<td>BOOLEAN</td>
</tr>
<tr>
<td>byte</td>
<td>tinyint</td>
<td>Int8</td>
<td>NUMBER(3,0)</td>
<td>tinyint</td>
<td>TINYINT</td>
</tr>
<tr>
<td>short</td>
<td>smallint tinyint unsigned</td>
<td>Int16 uint8</td>
<td>NUMBER(5,0)</td>
<td>smallint</td>
<td>SMALLINT</td>
</tr>
<tr>
<td>int</td>
<td>int mediumint smallint unsigned mediumint unsigned</td>
<td>Int32 uint16</td>
<td>NUMBER(10,0)</td>
<td>int</td>
<td>INT</td>
</tr>
<tr>
<td>long</td>
<td>bigint int unsigned</td>
<td>Int64 UInt32</td>
<td>NUMBER(20,0)</td>
<td>bigint</td>
<td>BIGINT</td>
</tr>
<tr>
<td>bigint<br/>（<em>java.math.BigInteger</em>）</td>
<td>bigint unsigned<br/>（<code>mysql官网不建议使用</code>）</td>
<td>Int128<br/>Int256<br/>uInt64<br/>uInt128<br/>uInt256</td>
<td></td>
<td></td>
<td><code>不支持</code>（java.sql.Types不支持，因此Flink SQL也不支持，DataStream api中的TypeInformation是支持的）</td>
</tr>
<tr>
<td>float</td>
<td>float float unsigned（<code>官网不建议使用</code>）</td>
<td>Float32</td>
<td>BINARY_FLOAT</td>
<td>float</td>
<td>FLOAT</td>
</tr>
<tr>
<td>double</td>
<td>double double unsigned（<code>官网不建议使用</code>）</td>
<td>Float64</td>
<td>BINARY_DOUBLE</td>
<td>double</td>
<td>DOUBLE</td>
</tr>
<tr>
<td>String</td>
<td>varchar char text tinytext mediumtext longtext</td>
<td>String uuid fixedString</td>
<td>VARCHAR2 NVARCHAR2 CHAR NCHAR LONG</td>
<td>string</td>
<td>STRING VARCHAR</td>
</tr>
<tr>
<td>decimal</td>
<td>decimal numeric precision</td>
<td>Decimal</td>
<td>NUMBER FLOAT</td>
<td></td>
<td>DECIMAL</td>
</tr>
<tr>
<td>date</td>
<td>date year</td>
<td>Date</td>
<td></td>
<td></td>
<td>DATE</td>
</tr>
<tr>
<td>time</td>
<td>time</td>
<td></td>
<td></td>
<td></td>
<td>TIME(0)</td>
</tr>
<tr>
<td>timestamp</td>
<td>timestamp datetime</td>
<td>datetime64</td>
<td>date（与mysql类型有歧义）</td>
<td>timestamp</td>
<td>TIMESTAMP</td>
</tr>
<tr>
<td>byte[]</td>
<td>blob binary varbinary tinyblob mediumblob longblob</td>
<td></td>
<td>RAW</td>
<td></td>
<td>BYTES</td>
</tr>
</tbody></table>
<pre><code>注：
对照表中每格第一个为优先级最高的，一对多时优先选择
对照不出来的，一律对照成String，此时需要进行类型强转（表示该存储没有可以直接对照的数据类型）
mysql bigint unsigned官网不建议适用，并且明确说明应使用String存储https://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html`
</code></pre>
<h1 id="进入客户端"><a href="#进入客户端" class="headerlink" title="进入客户端"></a>进入客户端</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">clickhouse-client -h 127.0.0.1 -m -u default --password 123456</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">-- 将数据导入到ReplacingMergeTree表</span><br><span class="line">insert into replace_log select * from raw_log;</span><br><span class="line"></span><br><span class="line">-- 触发合并，进行去重</span><br><span class="line">OPTIMIZE TABLE replace_log final;</span><br><span class="line"></span><br><span class="line">-- 删除原表的数据</span><br><span class="line">alter table raw_log delete where 1=1;</span><br><span class="line"></span><br><span class="line">-- 将ReplacingMergeTree表合并后的数据写回原表</span><br><span class="line">insert into raw_log select * from replace_log;</span><br></pre></td></tr></table></figure>

<h1 id="备份脚本"><a href="#备份脚本" class="headerlink" title="备份脚本"></a>备份脚本</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">#!/bin/bash</span><br><span class="line"></span><br><span class="line">OUTDIR=/usr/local/etl/backup/</span><br><span class="line"></span><br><span class="line">clickhouse-client --password=123456   -q &quot;SHOW DATABASES&quot; &gt; /usr/local/etl/backup/db.txt</span><br><span class="line">while read -r db</span><br><span class="line">do</span><br><span class="line">        clickhouse-client --password=123456 -q &quot;SHOW TABLES FROM $db&quot; &gt; /usr/local/etl/backup/table.txt</span><br><span class="line">        #echo &quot;--------------------------------$&#123;db&#125;&quot;</span><br><span class="line">        while read -r table</span><br><span class="line">        do</span><br><span class="line">                if [ &quot;$db&quot; == &quot;system&quot; ]; then</span><br><span class="line">                echo &quot;skip system db&quot;</span><br><span class="line">                continue 2;</span><br><span class="line">                fi</span><br><span class="line"></span><br><span class="line">                if [[ &quot;$table&quot; == &quot;.inner.&quot;* ]]; then</span><br><span class="line">                echo &quot;skip materialized view $table ($db)&quot;</span><br><span class="line">                continue;</span><br><span class="line">                fi</span><br><span class="line"></span><br><span class="line">                echo &quot;export table $table from database $db&quot;</span><br><span class="line"></span><br><span class="line">                # dump schema</span><br><span class="line">                clickhouse-client --password=123456 -q &quot;SHOW CREATE TABLE $&#123;db&#125;.$&#123;table&#125; format CSV&quot; &gt;&gt; &quot;$&#123;OUTDIR&#125;/schema.sql&quot;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">  done  &lt; `ls /usr/local/etl/backup/table.txt`</span><br><span class="line">done  &lt; `ls /usr/local/etl/backup/db.txt`</span><br></pre></td></tr></table></figure>

<h1 id="clickhouse中如何查询分区表分区及表容量查询"><a href="#clickhouse中如何查询分区表分区及表容量查询" class="headerlink" title="clickhouse中如何查询分区表分区及表容量查询"></a>clickhouse中如何查询分区表分区及表容量查询</h1><p>转载自<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_41018861/article/details/116149198">https://blog.csdn.net/qq_41018861/article/details/116149198</a></p>
<p>clickhouse中如何查询分区表分区及表容量–这个问题相信大家在使用clickhouse分区表时都会经常遇到，其实clickhouse表的元数据信息都存储在system.parts表中，可以通过该表对clickhouse上所有表进行查询表容量大小、行数、压缩率及分区信息等进行查询了解。</p>
<h2 id="1-system-parts表schema解析"><a href="#1-system-parts表schema解析" class="headerlink" title="1. system.parts表schema解析"></a>1. system.parts表<a target="_blank" rel="noopener" href="https://so.csdn.net/so/search?q=schema&spm=1001.2101.3001.7020">schema</a>解析</h2><p>system.parts表schema说明如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">`partition`（String）-- 分区名称。</span><br><span class="line">`name`（String）-- 数据部分的名称。</span><br><span class="line">`part_type`（String）-- 数据部分的存储格式。</span><br><span class="line">`active`（UInt8）-- 指示数据部分是否处于活动状态的标志。如果数据部分处于活动状态，则会在表中使用它。否则，将其删除。合并后，不活动的数据部分仍然保留。</span><br><span class="line">`marks`（UInt64）-- 标记数。要获得数据部分中的大约行数，请乘以marks索引粒度（通常为8192）（此提示不适用于自适应粒度）。</span><br><span class="line">`rows`（UInt64）-- 行数。</span><br><span class="line">`bytes_on_disk`（UInt64）-- 所有数据片段的总大小（以字节为单位）。</span><br><span class="line">`data_compressed_bytes`（UInt64）-- 数据片段中压缩数据的总大小。不包括所有辅助文件（例如，带标记的文件）。</span><br><span class="line">`data_uncompressed_bytes`（UInt64）-- 数据片段中未压缩数据的总大小。不包括所有辅助文件（例如，带标记的文件）。</span><br><span class="line">`marks_bytes`（UInt64）-- 带标记的文件的大小。</span><br><span class="line">`modification_time`（DateTime） --包含数据片段的目录被修改的时间。这通常对应于数据零件创建的时间。</span><br><span class="line">`remove_time`（DateTime）-- 数据片段变为非活动状态的时间。</span><br><span class="line">`refcount`（UInt32）-- 使用数据片段的位置数。大于2的值表示在查询或合并中使用了数据部分。</span><br><span class="line">`min_date`（Date）-- 数据片段中日期键的最小值。</span><br><span class="line">`max_date`（Date） -- 数据片段中日期键的最大值。</span><br><span class="line">`min_time`（DateTime）-- 数据片段中日期和时间键的最小值。</span><br><span class="line">`max_time`（DateTime）-- 数据片段中日期和时间键的最大值。</span><br><span class="line">`partition_id`（String）-- 分区的ID。</span><br><span class="line">`min_block_number`（UInt64）-- 合并后组成当前部分的数据片段的最小数量。</span><br><span class="line">`max_block_number`（UInt64）-- 合并后组成当前部分的最大数据片段数。</span><br><span class="line">`level`（UInt32）-- 合并树的深度。零表示当前零件是通过插入而不是通过合并其他零件来创建的。</span><br><span class="line">`data_version`（UInt64）-- 用于确定应将哪些突变应用于数据部分（版本高于的突变data_version）的编号。</span><br><span class="line">`primary_key_bytes_in_memory`（UInt64）-- 主键值使用的内存量（以字节为单位）。</span><br><span class="line">`primary_key_bytes_in_memory_allocated`（UInt64）-- 为主键值保留的内存量（以字节为单位）。</span><br><span class="line">`is_frozen`（UInt8）-- 显示分区数据备份存在的标志。1，备份存在。0，备份不存在。有关更多详细信息，请参见“冻结分区”。</span><br><span class="line">`database`（String）-- 数据库的名称。</span><br><span class="line">`table`（String）-- 表的名称。</span><br><span class="line">`engine`（String）-- 不带参数的表引擎的名称。</span><br><span class="line">`path`（字符串）-- 包含数据零件文件的文件夹的绝对路径。</span><br><span class="line">`disk`（字符串）-- 存储数据部分的磁盘的名称。</span><br><span class="line">`hash_of_all_files`（字符串）-- 压缩文件的sipHash128。</span><br><span class="line">`hash_of_uncompressed_files`（String）-- 未压缩文件（带有标记的文件，索引文件等）的sipHash128。</span><br><span class="line">`uncompressed_hash_of_compressed_files`（String）-- 压缩文件中的数据的sipHash128，就好像它们是未压缩的一样。</span><br><span class="line">`delete_ttl_info_min`（DateTime）-- TTL DELETE规则的日期和时间键的最小值。</span><br><span class="line">`delete_ttl_info_max`（DateTime）-- TTL DELETE规则的日期和时间键的最大值。</span><br><span class="line">`move_ttl_info.expression`（Array（String））-- 表达式数组。每个表达式定义一个TTL MOVE规则。</span><br><span class="line">`move_ttl_info.min`（Array（DateTime））-- 日期和时间值的数组。每个元素都描述了TTL MOVE规则的最小键值。</span><br><span class="line">`move_ttl_info.max`（Array（DateTime））-- 日期和时间值的数组。每个元素都描述了TTL MOVE规则的最大键值。</span><br><span class="line">`bytes`（UInt64）-- bytes_on_disk的别名。</span><br><span class="line">`marks_size`（UInt64）-- marks_bytes的别名。</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="2-查看数据库总体容量、行数、压缩率"><a href="#2-查看数据库总体容量、行数、压缩率" class="headerlink" title="2.查看数据库总体容量、行数、压缩率"></a>2.查看数据库总体容量、行数、压缩率</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">localhost :) SELECT</span><br><span class="line">:-]     sum(rows) AS `总行数`,</span><br><span class="line">:-]     formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">:-]     formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">:-] FROM system.parts;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    sum(rows) AS `总行数`,</span><br><span class="line">    formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">FROM system.parts</span><br><span class="line"></span><br><span class="line">Query id: 38b59b29-d394-48a3-9424-c7354270b8ea</span><br><span class="line"></span><br><span class="line">┌─────总行数─┬─原始大小─┬─压缩大小───┬─压缩率─┐</span><br><span class="line">│ 8751892418 │ 3.06 TiB │ 345.38 GiB │     11 │</span><br><span class="line">└────────────┴──────────┴────────────┴────────┘</span><br><span class="line"></span><br><span class="line">1 rows in set. Elapsed: 1.679 sec. Processed 18.14 thousand rows, 11.92 MB (10.80 thousand rows/s., 7.10 MB/s.)</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="3-查看数据表容量、行数、压缩率"><a href="#3-查看数据表容量、行数、压缩率" class="headerlink" title="3.查看数据表容量、行数、压缩率"></a>3.查看数据表容量、行数、压缩率</h2><p>在此查询一张测试标签表的信息</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line">--在此查询一张临时表的信息</span><br><span class="line">localhost :) SELECT</span><br><span class="line">:-]     table AS `表名`,</span><br><span class="line">:-]     sum(rows) AS `总行数`,</span><br><span class="line">:-]     formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">:-]     formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">:-] FROM system.parts</span><br><span class="line">:-] WHERE table IN (&#x27;label&#x27;)</span><br><span class="line">:-] GROUP BY table;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    table AS `表名`,</span><br><span class="line">    sum(rows) AS `总行数`,</span><br><span class="line">    formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">FROM system.parts</span><br><span class="line">WHERE table IN (&#x27;label&#x27;)</span><br><span class="line">GROUP BY table</span><br><span class="line"></span><br><span class="line">Query id: da621ae1-5a1b-4394-8ccd-db60bf628bfd</span><br><span class="line"></span><br><span class="line">┌─表名──┬─总行数─┬─原始大小─┬─压缩大小─┬─压缩率─┐</span><br><span class="line">│ label │      3 │ 86.00 B  │ 151.00 B │    176 │</span><br><span class="line">└───────┴────────┴──────────┴──────────┴────────┘</span><br><span class="line"></span><br><span class="line">1 rows in set. Elapsed: 0.005 sec.</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="4-查看数据表分区信息"><a href="#4-查看数据表分区信息" class="headerlink" title="4.查看数据表分区信息"></a>4.查看数据表分区信息</h2><p>查看测试表在20年12月的分区信息</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">--查看测试表在20年12月的分区信息</span><br><span class="line">localhost :) SELECT</span><br><span class="line">:-]     partition AS `分区`,</span><br><span class="line">:-]     sum(rows) AS `总行数`,</span><br><span class="line">:-]     formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">:-]     formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">:-] FROM system.parts</span><br><span class="line">:-] WHERE (database IN (&#x27;fct_boss&#x27;)) AND (table IN (&#x27;fct_boss_register_event&#x27;)) AND (partition LIKE &#x27;2020-12-%&#x27;)</span><br><span class="line">:-] GROUP BY partition</span><br><span class="line">:-] ORDER BY partition ASC;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    partition AS `分区`,</span><br><span class="line">    sum(rows) AS `总行数`,</span><br><span class="line">    formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`</span><br><span class="line">FROM system.parts</span><br><span class="line">WHERE (database IN (&#x27;fct_boss&#x27;)) AND (table IN (&#x27;fct_boss_register_event&#x27;)) AND (partition LIKE &#x27;2020-12-%&#x27;)</span><br><span class="line">GROUP BY partition</span><br><span class="line">ORDER BY partition ASC</span><br><span class="line"></span><br><span class="line">Query id: 3c4c68e7-bdf1-41c7-a337-ddbdc3dfab1b</span><br><span class="line"></span><br><span class="line">┌─分区────────┬─总行数──┬─原始大小───┬─压缩大小─────┬──压缩率─┐</span><br><span class="line">│ 2020-12-01 │  14060 │ 2.62 MiB  │ 810.42 KiB  │     30 │</span><br><span class="line">│ 2020-12-02 │  13010 │ 2.44 MiB  │ 759.27 KiB  │     30 │</span><br><span class="line">│ 2020-12-03 │  13918 │ 2.62 MiB  │ 817.41 KiB  │     30 │</span><br><span class="line">│ 2020-12-04 │  22038 │ 4.12 MiB  │ 1.26 MiB    │     31 │</span><br><span class="line">│ 2020-12-05 │  30104 │ 5.57 MiB  │ 1.72 MiB    │     31 │</span><br><span class="line">│ 2020-12-06 │  30606 │ 5.72 MiB  │ 1.74 MiB    │     30 │</span><br><span class="line">│ 2020-12-07 │  20413 │ 3.83 MiB  │ 1.16 MiB    │     30 │</span><br><span class="line">│ 2020-12-08 │  12305 │ 2.31 MiB  │ 711.07 KiB  │     30 │</span><br><span class="line">|  ......    |        |           |             |        |</span><br><span class="line">└────────────┴────────┴───────────┴─────────────┴────────┘</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="5-查看数据表字段的信息"><a href="#5-查看数据表字段的信息" class="headerlink" title="5.查看数据表字段的信息"></a>5.查看数据表字段的信息</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">localhost :) SELECT</span><br><span class="line">:-]     column AS `字段名`,</span><br><span class="line">:-]     any(type) AS `类型`,</span><br><span class="line">:-]     formatReadableSize(sum(column_data_uncompressed_bytes)) AS `原始大小`</span><br><span class="line">:-]     formatReadableSize(sum(column_data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">:-]     sum(rows) AS `行数`</span><br><span class="line">:-] FROM system.parts_columns</span><br><span class="line">:-] WHERE (database = &#x27;test&#x27;) AND (table = &#x27;label&#x27;)</span><br><span class="line">:-] GROUP BY column</span><br><span class="line">:-] ORDER BY column ASC ;</span><br><span class="line"></span><br><span class="line">SELECT</span><br><span class="line">    column AS `字段名`,</span><br><span class="line">    any(type) AS `类型`,</span><br><span class="line">    formatReadableSize(sum(column_data_uncompressed_bytes)) AS `原始大小`,</span><br><span class="line">    formatReadableSize(sum(column_data_compressed_bytes)) AS `压缩大小`,</span><br><span class="line">    sum(rows) AS `行数`</span><br><span class="line">FROM system.parts_columns</span><br><span class="line">WHERE (database = &#x27;test&#x27;) AND (table = &#x27;label&#x27;)</span><br><span class="line">GROUP BY column</span><br><span class="line">ORDER BY column ASC</span><br><span class="line"></span><br><span class="line">Query id: 6cbed55b-94e6-46c5-b965-93f71875bb39</span><br><span class="line"></span><br><span class="line">┌─字段名─────┬─类型──────────┬─原始大小─┬─压缩大小─┬─行数─┐</span><br><span class="line">│ childs     │ Array(String) │ 0.00 B   │ 0.00 B   │    3 │</span><br><span class="line">│ label_name │ String        │ 0.00 B   │ 0.00 B   │    3 │</span><br><span class="line">│ user_id    │ String        │ 0.00 B   │ 0.00 B   │    3 │</span><br><span class="line">└────────────┴───────────────┴──────────┴──────────┴──────┘</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="6-system-parts-columns表-schema解析"><a href="#6-system-parts-columns表-schema解析" class="headerlink" title="6. system.parts_columns表 schema解析"></a>6. system.parts_columns表 schema解析</h2><p>system.parts_columns表 schema说明如下：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">`partition`（String）-- 分区名称。</span><br><span class="line">`name`（String）-- 数据片段的名称。</span><br><span class="line">`part_type`（String）-- 数据片段的存储格式。</span><br><span class="line">`active`（UInt8）-- 指示数据部分是否处于活动状态的标志。如果数据部分处于活动状态，则会在表中使用它。否则，将其删除。合并后，不活动的数据部分仍然保留。</span><br><span class="line">`marks`（UInt64）-- 标记数。要获得数据部分中的大约行数，请乘以marks索引粒度（通常为8192）（此提示不适用于自适应粒度）。</span><br><span class="line">`rows`（UInt64）-- 行数。</span><br><span class="line">`bytes_on_disk`（UInt64）-- 所有数据部分文件的总大小（以字节为单位）。</span><br><span class="line">`data_compressed_bytes`（UInt64）-- 数据部分中压缩数据的总大小。不包括所有辅助文件（例如，带标记的文件）。</span><br><span class="line">`data_uncompressed_bytes` （UInt64） --数据部分中未压缩数据的总大小。不包括所有辅助文件 （例如，带标记的文件）。</span><br><span class="line">`marks_bytes` （UInt64） --带有标记的文件的大小。</span><br><span class="line">`modification_time` （DateTime） --包含数据部分的目录被修改的时间。这通常对应于数据零件创建的时间。</span><br><span class="line">`remove_time` （DateTime） --数据部分变为非活动状态的时间。</span><br><span class="line">`refcount` （UInt32） --使用数据部分的位置数。大于2的值表示在查询或合并中使用了数据部分。</span><br><span class="line">`min_date` （Date） --数据部分中日期键的最小值。</span><br><span class="line">`max_date` （Date） --数据部分中日期密钥的最大值。</span><br><span class="line">`partition_id` （String） --分区的ID。</span><br><span class="line">`min_block_number` （UInt64） --合并后组成当前部分的数据部分的最小数量。</span><br><span class="line">`max_block_number` （UInt64） --合并后组成当前部分的最大数据部分数。</span><br><span class="line">`level` （UInt32） --合并树的深度。零表示当前零件是通过插入而不是通过合并其他零件来创建的。</span><br><span class="line">`data_version` （UInt64） --用于确定应将哪些突变应用于数据部分 （版本高于的突变data_version）的编号。</span><br><span class="line">`primary_key_bytes_in_memory` （UInt64） --主键值使用的内存量 （以字节为单位）。</span><br><span class="line">`primary_key_bytes_in_memory_allocated` （UInt64） --为主键值保留的内存量 （以字节为单位）。</span><br><span class="line">`database` （String） --数据库名称。</span><br><span class="line">`table` （String） --表的名称。</span><br><span class="line">`engine` （String） --不带参数的表引擎的名称。</span><br><span class="line">`disk_name` （String） --存储数据部分的磁盘的名称。</span><br><span class="line">`path` （String） --包含数据零件文件的文件夹的绝对路径。</span><br><span class="line">`column` （String） --列的名称。</span><br><span class="line">`type` （String） --列类型。</span><br><span class="line">`column_position` （UInt64） --以1开头的表中列的顺序位置。</span><br><span class="line">`default_kind` （字符串）  --表达类型 （DEFAULT，MATERIALIZED，ALIAS作为默认值），或者如果没有定义它为空字符串。</span><br><span class="line">`default_expression` （String） --默认值的表达式，如果未定义，则为空字符串。</span><br><span class="line">`column_bytes_on_disk` （UInt64） --列的总大小，以字节为单位。</span><br><span class="line">`column_data_compressed_bytes` （UInt64） --列中压缩数据的总大小，以字节为单位。</span><br><span class="line">`column_data_uncompressed_bytes` （UInt64） --列中解压缩数据的总大小，以字节为单位。</span><br><span class="line">`column_marks_bytes` （UInt64） --带标记的列的大小，以字节为单位。</span><br><span class="line">`bytes` （UInt64） --的别名bytes_on_disk。</span><br><span class="line">`marks_size` （UInt64） --的别名marks_bytes。</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="flink正常启动和checkPoint恢复启动"><a href="#flink正常启动和checkPoint恢复启动" class="headerlink" title="flink正常启动和checkPoint恢复启动"></a>flink正常启动和checkPoint恢复启动</h1><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">#正常启动</span><br><span class="line">cd  /usr/local/etl/flink/flink/bin</span><br><span class="line">./flink run -c com.ziyi.cdc.intercity.ExecuteCdc -p 1 /usr/local/etl/ziyi_cdc/cdc-0.0.1-SNAPSHOT-jar-with-dependencies.jar</span><br><span class="line">参数含义：</span><br><span class="line">    -c 启动类路径（com.ziyi.cdc.intercity.ExecuteCdc）</span><br><span class="line">    -p 1   并行度等于1</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">--从checkPoint恢复启动</span><br><span class="line">cd  /usr/local/etl/flink/flink/bin</span><br><span class="line">./flink run -s file:///home/hdfs/cdc-point/ck/dc9b7e1fff60f393277b607c7df009af/chk-964120 -c  com.ziyi.cdc.intercity.ExecuteCdc  /usr/local/etl/ziyi_cdc/cdc-0.0.1-SNAPSHOT-jar-with-dependencies.jar</span><br><span class="line">参数含义：</span><br><span class="line">      1、 -s    指定checkPoint/savePoint的路径（file:///home/hdfs/cdc-point/ck/ef2d8d8939bd5b5189ab8ddc30e87475/chk-49）</span><br><span class="line">                文件恢复路径，固定不变file:///home/hdfs/cdc-point/ck/</span><br><span class="line">                最新的检查点文件夹，用时间最接近的，chk-49原则用最大编号的文件夹  ef2d8d8939bd5b5189ab8ddc30e87475/chk-49</span><br><span class="line">      2、-c     启动类路径（com.ziyi.cdc.intercity.ExecuteCdc）</span><br><span class="line">      3、jar路径（/usr/local/etl/ziyi_cdc/cdc-0.0.1-SNAPSHOT-jar-with-dependencies.jar）</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://blog.cydh.top/2023/08/16/clickHouse%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2023/08/18/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E5%9F%BA%E7%A1%80/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            数据结构基础
          
        </div>
      </a>
    
    
      <a href="/2023/08/14/linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">linux常用命令</div>
      </a>
    
  </nav>

  
   
  
   
    <script src="https://cdn.staticfile.org/twikoo/1.4.18/twikoo.all.min.js"></script>
    <div id="twikoo" class="twikoo"></div>
    <script>
        twikoo.init({
            envId: ""
        })
    </script>
 
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2023
        <i class="ri-heart-fill heart_icon"></i> cyd
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="风舞神者"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E6%97%85%E8%A1%8C/">旅行</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="http://shenyu-vip.lofter.com">摄影</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->
 <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/photoswipe/4.1.3/default-skin/default-skin.min.css">
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe.min.js"></script>
<script src="https://cdn.staticfile.org/photoswipe/4.1.3/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script> 
<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>